//
//  EGFreshModel.m
//  Orchard
//
//  Created by 黄勇锋 on 16/8/20.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "EGFreshModel.h"


@implementation EGFreshModel

- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
        
}

+ (instancetype)modelWithDict:(NSDictionary *)dict {
    
    EGFreshModel *model = [[EGFreshModel alloc]init];
    
    [model setValuesForKeysWithDictionary:dict];

    return model;
}


#pragma mark - getFresh
+ (void)getFreshSellDataWithSuccess:(void(^)(NSArray *))success failure:(void(^)(NSError *))failure{
    
    NSString *urlString = @"http://iosapi.itcast.cn/loveBeen/firstSell.json.php";
    NSDictionary *paramDic = @{
                               @"call":@"2",
                               };
    
    [[NetworkTool shareManager] POST:urlString parameters:paramDic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *  _Nullable responseObject) {
        
        NSArray *data = responseObject[@"data"];

        NSMutableArray *freshArray = [NSMutableArray array];
        
        [data enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            EGFreshModel *model = [EGFreshModel modelWithDict:obj];
            [freshArray addObject:model];
            
        }];
        
        success(freshArray.copy);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        failure(error);
    }];
}



@end
